import redis


class redisPool():
    def __init__(self):
        Pool = redis.ConnectionPool(host='127.0.0.1', port=6379, max_connections=100, encoding='utf-8', db=0)
        # 从池子中拿一个链接
        self.conn = redis.Redis(connection_pool=Pool, decode_responses=True)

    def redis_get(self, redis_key):
        result = self.conn.get(redis_key)
        if result:
            result = result.decode()
        return result

    def redis_del(self, redis_key):
        result = self.conn.delete(redis_key)
        return result
